package com.jf3q.front.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.jf3q.common.domain.EduBanner;
import com.jf3q.common.vo.ResultVo;
import com.jf3q.front.service.BannerFrontService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 前台bannber显示
 * </p>
 *
 * @author testjava
 * @since 2020-03-07
 */
@RestController
@RequestMapping("/bannerfront")
public class BannerFrontController {

    @Autowired
    private BannerFrontService bannerService;

    //查询所有banner
    @GetMapping
    public ResultVo getAllBanner() {

        LambdaQueryWrapper<EduBanner> queryWrapper= new LambdaQueryWrapper<>();
        queryWrapper.orderByDesc(EduBanner::getEduCreate);
        //last方法，拼接sql语句
        queryWrapper.last("limit 2");//显示最新的两个图
        List<EduBanner> list = bannerService.list();
        return ResultVo.success(list);
    }
}
